<div id="SoftwareInfo">
<h1>Welcome to the software section</h1><br />
<p>You can look at individual software titles by clicking on their name in the left column.</p>
<p>If you ever need help with any of our software, feel free to go to our <a href="http://www.terranika.com/help">help forums</a> where you can ask our staff and other users questrions about the software.</p>
<h3>Popular Downloads:</h3><br />
<ul>
{php}
// Connect to Database
$link = mysql_connect('localhost', 'dgrega_counter', 'counter');
$db_selected = mysql_select_db('dgrega_counter', $link);

// Get most popular downloads
$query = "SELECT `File`,`Count` FROM `downloads` ORDER BY `Count` DESC LIMIT 0 , 5 ";
$result = mysql_query($query);

// Display each of them 
while ($row = mysql_fetch_assoc($result)) {
	echo "<li>";
	echo "<a href=\"" . str_replace(".exe",".html",$row["File"]) . "\">";
	
	// PAD Stuff
	$file = str_replace(".exe",".xml",$row["File"]);
	$loopPAD = new PADFile("/home/dgrega/public_html/padded/softwareData/padfiles/". $file);
	$loopPAD->Load();
	
	echo $loopPAD->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Name");
	
	echo " &middot; " . number_format($row["Count"]) . " downloads</a></li>";
}
{/php}
</ul>
</div>